$(document).ready(function(){ 
//轮播图代码
	    var slide = $(".main-swiper");
	    //分页按钮
	    var aBtn = $(slide).find('.swiper-dots > li'),
	    //item集合
	       item = $(slide).find('.swiper-item'),
	    //图像个数
	       iSize = item.size(),
	    //切换索引
	       index = 0;
	       var timer=2000
	       var zIndex = 1;
	       var int;
	    $(slide).find('.swiper-change').click(function(){    //右边按钮点击
	        index++;
	        if(index>iSize-1){
	            index=0
	        }
	        change(index);
	    })
	    //分页按钮点击
	    aBtn.click(function(){
	    	var thisIndex = $(this).index();
	        change(thisIndex);
	    });
	    //切换过程
	    function change(index){
	    	 clearInterval(int);
	    	 int = setInterval(autoshow,timer*2);
			item.stop();
	        aBtn.removeClass('active');
	        aBtn.eq(index).addClass('active');
	        //隐藏除了当前元素所有元素
	        $(item).each(function(index1){
	            if(index1 != index ){
	            	$(this).animate({ 
	            		opacity:0
	            	},1000);
	            }
	        });

		 	item.eq(index).css({
		 		display:'block'
		 	}).animate({ 
		 		opacity:1
		 	},timer);
		 	zIndex++;
		 	item.eq(index).css({
		 		'z-index':zIndex
		 	})
	    }
	    
	    function autoshow() {
	        index = index+1;
	        if(index <= iSize - 1){
	            change(index);
	        }else{
	            index=0;
	            change(index);
	        }

	    }
	    int = setInterval(autoshow,timer*2);
	    function clearInt () {
	        item.mouseover = aBtn.mouseover = function() {
	            clearInterval(int);
	        };
	    }
	    function setInt() {
	    	item.mouseout = aBtn.mouseout = function() {
	           int = setInterval(autoshow,timer*2);
	        };
	    }
	    clearInt();
	    setInt();
})